home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / Z4CSPRE.C < prev    next >
C/C++ Source or Header  |  1995-08-20  |  4KB  |  154 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    z4cspre.c
  5. //   Title:    9-Digit ZIP Code Directory -- on CD-ROM
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains the program entry point for
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <z4.h>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //    Stack size
  45. //----------------------------------------------------------------------------
  46. #if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
  47. unsigned _stklen = 0x4000;
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //    Globals
  53. //----------------------------------------------------------------------------
  54.  
  55. //
  56. // A useless string which is simply embedded in the executable.
  57. //
  58. PSZ __pszCredits__ = "Written by John M Weeder, 1993";
  59.  
  60.  
  61. //
  62. //    This should contain a program description which will be displayed as
  63. //    part of the program's help text.
  64. //
  65. static PCSZ pcszDescription =
  66.     "This program pre-processes the city state file.";
  67.  
  68. //
  69. //    Program command line options
  70. //
  71. static DATACFG dcfg;
  72. static CHAR szConfig[MAX_PATH] = "z4cs";
  73. static BS_CMDOPT acmdopt[] =
  74.     {
  75.     { "config", (PVOID)szConfig,        CMDOPT_FILESPECR(80),     "Configuration file name."},
  76.     { "input",     (PVOID)dcfg.szInput,    CMDOPT_FILESPEC(80),        "Input file name."},
  77.     BS_CMDOPT_NULL,
  78.     };
  79.  
  80.  
  81. //----------------------------------------------------------------------------
  82. //   Description:    
  83. //    Parameters:
  84. //       Returns:    
  85. //----------------------------------------------------------------------------
  86. BOOL FN_E Z4CSPre(PDATACFG pcfg, PSZ _FAR_ *apsz, PBYTE pb, SIZET cb)
  87. {
  88. static SIZET cPof;
  89. static SIZET cState;
  90. static BOOL fInit = FALSE;
  91. static PZ4_PF_TBL ppf_tbl = NULL;
  92.  
  93.     NOTUSED(pb);
  94.     NOTUSED(cb);
  95.     if (apsz == NULL) {
  96.         if (!fInit) {
  97.           Z4PofCreate(&ppf_tbl, Z4_PF_TBL_DISCARD_MAX);
  98.           fInit = TRUE;
  99.         }  else {
  100.         Z4PofWrite(ppf_tbl, Z4_PF_TBL_DISCARD);
  101.         Z4PofDestroy(ppf_tbl);
  102.         }
  103.           cPof = DataField(pcfg, "finance");
  104.           cState = DataField(pcfg, "state_abbrev");
  105.           return FALSE;
  106.     }
  107.                                              // Check state code
  108.     if (Z4FindState(apsz[cState]) != Z4_ST_INVALID)
  109.          return FALSE;
  110.  
  111.     Z4PofAdd(ppf_tbl, apsz[cPof]);
  112.     return FALSE;
  113. }
  114.  
  115.  
  116. //----------------------------------------------------------------------------
  117. //   Description:    main() - Program entry point
  118. //    Parameters:    Standard C parameters
  119. //       Returns:    DOS return code.
  120. //----------------------------------------------------------------------------
  121. int main(int argc, char **argv)
  122. {
  123. static BS_CFG cfg = CFG_DFT;
  124.     SHORT retval;
  125.  
  126.     //
  127.     //    Initialize base library
  128.     //
  129.     BaseLibraryInitialize(argc, argv, &cfg);
  130.     BaseTitle("$Revision:  93.1  $", __DATE__, __TIME__, "City/State File Preprocess Utility");
  131.     if (!BaseTitleHelp(acmdopt, pcszDescription,0))
  132.         return 99;
  133.  
  134.     DioSetDataPath(getenv("DATA"));
  135.     dcfg.fInit = TRUE;
  136.     if (!DataConfigRead(szConfig, &dcfg))
  137.         {
  138.         Output("Failed reading configuration file.\n");
  139.         goto ERROR_EXIT;
  140.         }
  141.     if (!DataPreProcess(&dcfg, Z4CSPre))
  142.         {
  143.         Output("Failed preprocessing file.\n");
  144.         goto ERROR_EXIT;
  145.         }
  146.     retval = 0;
  147. ERROR_EXIT:
  148.     DioCloseAll();
  149.     return retval;
  150. }
  151. //----------------------------------------------------------------------------
  152. //------------------------------- End of File --------------------------------
  153. //----------------------------------------------------------------------------
  154.